<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>绩效批量导入 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div id="ligergrid1" class="sq-grid"></div>
    <c:if test="${success==true and not empty fundList}">
        <div class="btnsBox" style="text-align: center;">
            <span id="saveInsPlcBscInfo_Btn" class="sq-button sq-button-round l-dialog-btn-ok">确认导入</span>
        </div>
    </c:if>
    <c:if test="${success==false or empty fundList}">
        <div class="btnsBox" style="text-align: center;">
            <span id="close_Btn" class="sq-button sq-button-round co_normal">关闭</span>
        </div>
    </c:if>
</div>

<script type="text/javascript">
    var grid = null;
    var callback = null;
    $(function () {
        var filePath='${filePath}';
        var fileNm='${fileNm}';
        grid = $("#ligergrid1").ligerGrid({
            columns: [
                      { display: '提成所属月份', name: 'achMth',  width: 100, enabledSort:false},
      	            { display: '提成发放月份', name: 'achPayMth',  minWidth: 200, enabledSort:false},
      	            { display: '省份', name: 'proNm',  width: 120, enabledSort:false},
      	            { display: '工号', name: 'usrCd',  width: 100, enabledSort:false},
      	            { display: '应提成人', name: 'usrNm', minWidth: 120 , enabledSort:false,
      	            	render: function (rowdata, rowindex, value){
      	        			return UIUtils.showColumnTip(value);
      	            	}
      	            },
      	            { display: '应提成人组织架构', name: 'usrOrgCd', minWidth: 100 , enabledSort:false},
      	            { display: '应提成人所属公司', name: 'usrOrgNm', width: 60,align:'left' , enabledSort:false},
      	            { display: '应提成人职能', name: 'usrFunNm', minWidth: 100 , enabledSort:false},
      	            { display: '提成所属人员岗位', name: 'usrPostNm', minWidth: 120 , enabledSort:false,
      	            	render: function (rowdata, rowindex, value){
      	        			return UIUtils.showColumnTip(value);
      	            	}
      				},
      	            { display: '支付表号', name: 'paySchNo', minWidth: 80 , enabledSort:false},
      	            { display: '客户名称', name: 'cstNm', minWidth: 140 , enabledSort:false},
      	            { display: '提成类别(放款提成&回款提成&考察费)', name: 'achTypNm', minWidth: 140 , enabledSort:false},
      	            { display: '业务类型(车队业务、城配业务、传统业务旧政策、传统业务新政策、再融资)', name: 'buTypNm', minWidth: 140 , enabledSort:false},
      	            { display: '标准发放金额 (未考虑任何考核)', name: 'achAmt', minWidth: 140 , enabledSort:false},
      	            { display: '实际发放金额', name: 'realAchAmt', minWidth: 100 , enabledSort:false},
   	                { display: '发放系数', name: 'outNmb', minWidth: 50 , enabledSort:false},
            ],
            usePager: true,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers: true,
            alternatingRow:false,
            allowUnSelectRow: true,
            rowAttrRender: function (rowdata,rowid){
                if (rowdata.fundStatusCd == "0")
                {
                    return "style='background:green;'";
                }else{
                    return "style='background:red;'";
                }
            }
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        var jsonObj = {};
        <c:if test="${not empty fundList}">
            jsonObj.rows = ${fundList};
        </c:if>
        grid.set({data: jsonObj});

        /* 导入 */
        $("#saveInsPlcBscInfo_Btn").click(function (event) {
        	
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {filePath:filePath,fileNm:fileNm},
                url: '<%=path%>/bizflow/rskUsrAchLog/importAchievements.do',
                beforeSend: function () {
                    wait_dialog = top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        parent.$("#searchBtn").click();
                        frameElement.dialog.close();
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                },
                error:function(){
                    wait_dialog.close();
                    top.$.ligerDialog.SQalert({content: "绩效导入失败,请稍后重试", SQ_type: "error"});
                }
            });
        }); 

        //关闭
        $("#close_Btn").click(function (event) {
            frameElement.dialog.close();
        });

    });

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>

</body>
</html>
